// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Talina Gaming System (TgS) (∂)
//  »File«      TgS (XB2) Common - Math API [Vector] [S08].inl
//  »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
//  »Version«   4.0
// ------------------------------------------------------------------------------------------------------------------------------ //
//  Copyright: © 2002-2010, Andrew Aye.  All Rights Reserved.
//  This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification,
//  are permitted provided that the following conditions are met: 
//    Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. 
//    Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following
//      disclaimers in the documentation and other materials provided with the distribution. 
//  Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived
//  from this software without specific prior written permission. 
//  The intellectual property rights of the algorithms used reside with Andrew Aye.  You may not use this software, in whole or
//  in part, in support of any commercial product without the express written consent of the author.
//  There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
#if !defined(_TGS_XB2_COMMON_MATH_API_VECTOR_S08_INL_)
#define _TGS_XB2_COMMON_MATH_API_VECTOR_S08_INL_
#pragma once


// START TGS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// START MATH //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// ============================================================================================================================== //
// -- TTgVECTOR (TgSINT08,16) --------------------------------------------------------------------------------------------------- //
// ============================================================================================================================== //

// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Forward Declarations
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

template <> TgVEC_S08_16 M_MAX<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_MIN<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );

template <> TgVEC_S08_16 M_CMP_EQ<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_CMP_NE<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_CMP_GE<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_CMP_GT<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_CMP_LE<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_CMP_LT<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );

template <> TgVEC_S08_16 M_ADD_S<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_ADD_M<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_SUB_S<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_SUB_M<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );
template <> TgVEC_S08_16 M_AVG<TgSINT08,16>( M_TgVEC_S08_16, M_TgVEC_S08_16 );




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Native to TGS Vector Type
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_S08_16 M_TgVECTOR<TgSINT08,16>( const __vector4 vNative )
{
    register TgVEC_S08_16 tvResult;
    tvResult.m_mData = vNative;
    return (tvResult);
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Bounds
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_S08_16 M_MAX<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vmaxsb( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_MIN<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vminsb( tvLeft.m_mData, tvRight.m_mData ) ));
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Comparison Operators
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_S08_16 M_CMP_EQ<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vcmpequb( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_CMP_NE<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vxor( TgKV_FFFF.m_mData, __vcmpequb( tvLeft.m_mData, tvRight.m_mData ) ) ));
}


TgINLINE TgVEC_S08_16 M_CMP_GE<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vxor( TgKV_FFFF.m_mData, __vcmpgtgb( tvRight.m_mData, tvLeft.m_mData ) ) ));
}


TgINLINE TgVEC_S08_16 M_CMP_GT<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vcmpgtgb( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_CMP_LE<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vxor( TgKV_FFFF.m_mData, __vcmpgtgb( tvLeft.m_mData, tvRight.m_mData ) ) ));
}


TgINLINE TgVEC_S08_16 M_CMP_LT<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vcmpgtgb( tvRight.m_mData, tvLeft.m_mData ) ));
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Arithmetic Operations
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_S08_16 M_ADD_S<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vaddsbs( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_ADD_M<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vaddubm( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_SUB_S<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vsubsbs( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_SUB_M<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vsububm( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_S08_16 M_AVG<TgSINT08,16>( M_TgVEC_S08_16 tvLeft, M_TgVEC_S08_16 tvRight )
{
    return (M_TgVECTOR<TgSINT08,16>( __vavgsb( tvLeft.m_mData, tvRight.m_mData ) ));
}




// END MATH ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// END TGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //  END  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////